//
//  LoginViewController.m
//  Four_Fit
//
//  Created by xalo on 16/7/13.
//  Copyright © 2016年 xmaz. All rights reserved.
//

#import "LoginViewController.h"
#import "RetrieveViewController.h"
#import "InitViewController.h"
#import "LoginModel.h"

/**
 *  登录界面
 */

@interface LoginViewController ()<UITextFieldDelegate>
@property (weak, nonatomic) IBOutlet UITextField *idTextField;          //账号输入框
@property (weak, nonatomic) IBOutlet UITextField *passwordTextField;    //密码输入框
@property (weak, nonatomic) IBOutlet UIButton *loginBtn;                //登录
@property (weak, nonatomic) IBOutlet UIButton *foundBtn;                //找回密码
@property (weak, nonatomic) IBOutlet UIButton *QQLoginBtn;              //QQ第三方登录
@property (weak, nonatomic) IBOutlet UIButton *WeboLoginBtn;            //微博第三方登录


@end

@implementation LoginViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.idTextField.clearsOnBeginEditing = YES;

    self.idTextField.returnKeyType = UIReturnKeyNext;
    self.passwordTextField.returnKeyType = UIReturnKeyGo;
    
    self.passwordTextField.delegate = self;
    
}


- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
    
    self.passwordTextField.clearsOnBeginEditing = YES;
    
    return YES;
}

- (void)textFieldDidBeginEditing:(UITextField *)textField {
    
    if ((self.passwordTextField.clearsOnBeginEditing = YES)) {
        
        self.passwordTextField.secureTextEntry = YES;
    }
}
//登录事件
- (IBAction)loginBtnAction:(id)sender {
    
    [[QZRequestManager sharedManager]fetchDataWithUrl:@"http://ws.sythealth.com/ws/fit/v4/user/login" parameters:@{@"account":self.idTextField.text, @"product":@"fit",@"channel":@"App Stroe",@"isgetslim":@"0",@"isgetstask":@"0",@"mobileid":@"1a5b52fc7fc2e077cf1810f9e3dedeb5c91d7e54",@"loginway":@"bymobile",@"desc":@"IOS",@"pwd":self.passwordTextField.text} method:@"POST" needToCaches:NO fetchData:^(NSData *data) {
        
        NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:nil];
        NSLog(@"%@",dic);
        
        
    } updateUI:^{
        
        
    }];

}

- (void)LoginWithSuccess {
    
    [[QZRequestManager sharedManager]fetchDataWithUrl:@"http://ws.sythealth.com/ws/fit/v4_3/feed/getfeedbyuser?feeduserid=5784f2a8dfdca14c42e6dc64&page=1&tokenid=tokenid_undefined&userid=5784f2a8dfdca14c42e6dc64" parameters:@{@"feeduserid":@"5784f2a8dfdca14c42e6dc64",@"page":@"1",@"tokenid":@"tokenid_undefined",@"userid":@"5784f2a8dfdca14c42e6dc64"} method:@"GET" needToCaches:YES fetchData:^(NSData *data) {
        
        NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:nil];
        NSLog(@"%@",dic[@"data"][@"getSlimsmaStage"]);
    } updateUI:^{
        
    }];
}
//找回密码
- (IBAction)foundBtnAction:(id)sender {
    
    RetrieveViewController *retrieveVC = [[RetrieveViewController alloc]init];
    UINavigationController *retrieve = [[UINavigationController alloc]initWithRootViewController:retrieveVC];
    [self.navigationController presentViewController:retrieve animated:YES completion:nil];
}

//QQ第三方登录
- (IBAction)QQLoginBtnAction:(id)sender {
    
    
    }

//微博登录
- (IBAction)WeboLoginBtnAction:(id)sender {
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
